package com.lyf.design.learn.designmodel.observer.test;

import java.util.Random;

/**
 * @AUTHOR LYF
 * @DATE 2022/6/10
 * @VERSION 1.0
 * @DESC
 */
public class Subject1 extends Subject{
    Double temperature=36.0;

    public Double getTemperature() {
        return temperature;
    }

    public void setTemperature(Double temperature) {
        this.temperature = temperature;
    }

    void addTmp(Double addVal){
        temperature+=addVal;
    }

    @Override
    void change() {
        Double addVal = new Random().nextDouble();
        addTmp(addVal);
        for (Observer o:observerList){
            o.resp("温度增加了"+addVal+"C");
        }
    }
}
